package cn.itcast.music.util;

import android.text.format.DateFormat;
import java.util.Date;

public abstract class DateTimeUtil {

    private DateTimeUtil() {
    }

    public static String formatTime(long duration) {
        long minute = duration / 1000 / 60;
        long second = duration / 1000 % 60;
        String minuteStr;
        String secondStr;
        if (minute < 10) {
            minuteStr = "0" + minute;
        } else {
            minuteStr = minute + "";
        }
        if (second < 10) {
            secondStr = "0" + second;
        } else {
            secondStr = second + "";
        }
        return minuteStr + ":" + secondStr;
    }

    public static String formattedDateTimeNow() {
        // 格式为 YYYY-MM-DD hh:mm
        return DateFormat.format("yyyy-MM-dd HH:mm", new Date()).toString();
    }

}
